- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 456
 
Double pinyin query #2427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Double pinyin query #2427
Conversation
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
73c4a69    to
    22f6ad7      
    Compare
  
    | 
           @VictoriousRaptor what's the status of this pr?  | 
    
          
 POC. I'm using it daily and so far so good. Since there're many double pinyin mappings we should make it user configurable. Is it acceptable to allow users to edit a json file that defines the mapping?  | 
    
| 
           well I can't think anything better...maybe I do want this to be plugin-able, but can't think of a good way to design the api.  | 
    
0c01c95    to
    f673000      
    Compare
  
    
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds support for Double Pinyin in search by exposing new toggles in the UI, loading a JSON-based mapping table, and wiring it through settings, view models, and the PinyinAlphabet.
- UI: new switch and combo box for enabling double-pinyin and selecting a schema
 - Settings & ViewModel: new 
UseDoublePinyinandDoublePinyinSchemaproperties, with binding and localization - Core logic: JSON file of mappings, loading in 
PinyinAlphabet, and a newTranslationMappingclass with unit tests 
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description | 
|---|---|
| SettingPages/Views/SettingsPaneGeneral.xaml | Added cards/toggles and schema selector | 
| SettingsPaneGeneralViewModel.cs | Introduced UseDoublePinyin, schema list | 
| Resources/double_pinyin.json | New mapping table for all supported schemas | 
| Languages/en.xaml | Added localization for toggles and schemas | 
| Flow.Launcher.csproj | Ensured JSON is copied to output | 
| TranslationMapping.cs | New mapping utility with AddNewIndex/MapToOriginalIndex | 
| TranslationMappingTest.cs | Unit tests for TranslationMapping | 
| UserSettings/Settings.cs | Added settings, JSON serialization, enum | 
| Infrastructure/StringMatcher.cs | Switched to ShouldTranslate predicate | 
| Infrastructure/PinyinAlphabet.cs | Loads JSON, applies double-pinyin translation | 
| Infrastructure/IAlphabet.cs | Updated interface to use ShouldTranslate | 
Comments suppressed due to low confidence (3)
Flow.Launcher.Infrastructure/TranslationMapping.cs:29
- Method name 'endConstruct' doesn't follow .NET naming conventions; consider renaming to 'EndConstruct'.
 
        public void endConstruct()
Flow.Launcher.Infrastructure/TranslationMapping.cs:29
- The behavior of 
endConstructisn't covered by unit tests; consider adding tests to verify it prevents further calls toAddNewIndexafter construction. 
        public void endConstruct()
Flow.Launcher/Flow.Launcher.csproj:130
- Using 'Update' for a new resource entry may not include the JSON in the build; consider using 'Include' or verify that default globbing picks it up so it’s reliably copied under the Resources folder at runtime.
 
    <None Update="Resources\double_pinyin.json">
| 
           LGTM  | 
    
| 
           This feature is really awesome, thank you for your effort!  | 
    
This pull request introduces a comprehensive set of changes to enhance Pinyin support in the application, including the addition of Double Pinyin (“双拼”) functionality, improved translation mappings, and related settings. The most significant updates include the implementation of the
IAlphabetinterface, the refactoring of thePinyinAlphabetclass, the introduction of Double Pinyin schemas, and updates to the user settings and localization files.UI in General Panel
Pinyin and Double Pinyin Enhancements:
IAlphabetinterface to define methods for language translation and determining translatability. (Flow.Launcher.Infrastructure/IAlphabet.cs)PinyinAlphabetclass to support Double Pinyin, utilize a cache for translations, and dynamically reload schemas based on user settings. (Flow.Launcher.Infrastructure/PinyinAlphabet.cs)Flow.Launcher.Infrastructure/UserSettings/Settings.cs) [1] [2]Translation Mapping Improvements:
TranslationMappingclass to simplify and optimize the mapping of original to translated indices. (Flow.Launcher.Infrastructure/TranslationMapping.cs)TranslationMappingto validate its functionality. (Flow.Launcher.Test/TranslationMappingTest.cs)Localization and Resource Updates:
Flow.Launcher/Languages/en.xaml)double_pinyin.jsonto project resources for schema definitions. (Flow.Launcher/Flow.Launcher.csproj)Codebase Simplifications:
StringMatcher.csto use the newShouldTranslatemethod fromIAlphabet. (Flow.Launcher.Infrastructure/StringMatcher.cs)IsAcronymandIsAcronymCountstatic for better encapsulation. (Flow.Launcher.Infrastructure/StringMatcher.cs) [1] [2]